import axios from "axios";

const instance = axios.create({
  baseURL: "/api",
  timeout: 10000,
  headers: {
    "Content-Type": "application/json;charset=UTF-8",
  },
});

instance.interceptors.request.use((config) => {
  return config;
});

instance.interceptors.response.use((res) => {
  return res.data;
});

instance.get = function (url, options = {}) {
  return instance({
    method: "get",
    url,
    ...options,
  });
};

instance.post = function (url, options = {}) {
  return instance({
    method: "post",
    url,
    ...options,
  });
};

export default instance;
